package com.canyou.redmine.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.canyou.redmine.R;
import com.canyou.redmine.model.Issue;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by user on 2018/1/8.
 */

public class TaskAdapter extends BaseQuickAdapter<Issue, BaseViewHolder> {
    private Context context;
    private List<Issue> list;

    public TaskAdapter(Context context, int layoutResId, @Nullable List<Issue> data) {
        super(layoutResId, data);
        this.context = context;
        this.list = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, Issue item) {
        helper.setText(R.id.tv_issue_id, "#" + item.getId())
                .setText(R.id.tv_issue_title, item.getSubject())
                .setText(R.id.tv_due_date, item.getDue_date())
                .setText(R.id.tv_priority, item.getPriority().getName())
                .setText(R.id.tv_tracker,item.getTracker().getName())
                .setText(R.id.tv_project_name, item.getProject() == null ? "" :
                        item.getProject().getName())
                .setProgress(R.id.progressBar, item.getDone_ratio());

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
    }
}
